package liangtWorkSpace.base.ifElse;

/**
 * @ClassName IfElesBase
 * @Description : 大量if-else基础示例
 * @Author : LiangT
 * @Date : 2020/5/15 12:47
 */
public class IfElesBase {
    public static int calculate(int a, int b, String operator) {
        int result = Integer.MIN_VALUE;

        if ("add".equals(operator)) {
            result = a + b;
        } else if ("multiply".equals(operator)) {
            result = a * b;
        } else if ("divide".equals(operator)) {
            result = a / b;
        } else if ("subtract".equals(operator)) {
            result = a - b;
        } else if ("modulo".equals(operator)) {
            result = a % b;
        }
        return result;
    }
}
